package com.TeamJigsaw.DanteTrail.Models;

import java.util.Random;

/**
 * A UGA student randomly steals one of your items (RandomEvent)
 * @author Vince
 *
 */
public class ThiefEvent extends RandomEvent {

	private String eventMessage;

	private Random generator;
	
	public  ThiefEvent(){
		this.eventMessage = null;
		generator = new Random();
	}
	@Override
	public boolean performEvent(Party party){
		int randNum = generator.nextInt(101);
		int pace = party.getPace();
		double multiply = 0.00;
		if (pace == 5){
			multiply = 1.20;
		}
		else if (pace == 10){
			multiply = 1.15;
		}
		else if (pace == 15){
			multiply = 1.10;
		}
		else if (pace == 20){
			multiply = 1.05;
		}

		double newRand = randNum * multiply;

		if (newRand > 100){
			newRand = generator.nextInt(76) + 1;
			if (newRand < 12){ //Clothes are stolen
				if(party.getClothes() > 0){
					int maxClothesRemoved = (int)(party.getClothes() * .1);
					double percentRemoved = newRand / 12;
					int clothes = (int)(maxClothesRemoved * percentRemoved) + 1;
					party.addClothes(-clothes);
					eventMessage = "A UGA student stole " + clothes + " clothes!";
				}
				else {
					eventMessage = "A UGA student tried to steal clothes, but you're all out.";
				}
			}
			else if (newRand < 25){ //Food is stolen
				if(party.getFood() > 0){
					int maxFoodRemoved = (int)(party.getFood() * .1);
					double percentRemoved = newRand / 25;
					int food = (int)(maxFoodRemoved * percentRemoved) + 1;
					party.addFood(-food);
					eventMessage = "A UGA student stole " + food + " food!";
				}
				else {
					eventMessage = "A UGA student tried to steal food, but you're all out.";
				}
			}
			else if (newRand < 38){ // Some random Ammo is stolen (less than 10%)
				if(party.getAmmo() > 0){
					int maxAmmoRemoved = (int)(party.getAmmo() * .1);
					double percentRemoved = newRand / 38;
					int ammo = (int)(maxAmmoRemoved * percentRemoved) + 1;
					party.addAmmo(-ammo);
					eventMessage = "A UGA student stole " + ammo + " ammo!";
				}
				else {
					eventMessage = "A UGA student tried to steal ammo, but you're all out.";
				}
			}
			else if (newRand < 50){ // One Wheels are stolen
				if (party.getWheels() > 0)
					party.addWheels(-1);
				eventMessage = "A UGA student stole a wheel!";
			}
			else if (newRand < 63){ // One Axel is stolen
				if (party.getAxels() > 0)
					party.addAxels(-1);
				eventMessage = "A UGA student stole an axel!";
			}
			else if (newRand < 75){ // One Tongue is stolen
				if (party.getTongue() > 0)
					party.addTongues(-1);
				eventMessage = "A UGA student stole a tongue!";
			}
			return true;
		}
		else {
			return false;
		}

	}

	@Override
	public String getMessage(){

		return eventMessage;

	}
		/**
	 * Sets the beginning of the RandomEvent description
	 * @param eventMessage The beginning of the RandomEvent description
	 */
	public void setMessage(String eventMessage){
		this.eventMessage = eventMessage;
	}

	/**
	 * Returns a string representation of the class
	 * @return A string representation of the class
	 */
	@Override
	public String toString() {
		return ("This is a wagon event class");
	}
}

